const Mock = require('mockjs')
const fs = require('fs')
const types = ['男科', '妇科', '儿科', "内科", "外壳", "骨科", "口腔科", '急诊']
const data = Mock.mock({
	"goodList|1000": [{
		"title": "@ctitle",
		"image": "https://robohash.org/@id?set=set@integer(1,5)",
		"price|100-1000.2-4": 1,
		"count|10-20": 1,
		"desc": "@cword(20, 50)",
		"state": false,
		"type|1": ["衣服", "鞋子", "化妆品", "数码", "生活", "食品", "饰品", "药品", "体育", "儿童", "汽车"],
		"city": "@city",
		"type|1": types,
		"disCount|10-100": 1,
		"score|1-5": 1
	}]
})

function switchUniAppJSON(data, target) {
	const goodList = JSON.stringify(data)
		.replace('[', '')
		.replace(']', '')
		.replace(/\},\{/g, '}{');
	fs.writeFileSync(target, goodList)
}

switchUniAppJSON(data.goodList, './goodList.json')